
// 路由拦截器组件
import { withRouter,Prompt } from "react-router-dom"


const MyPrompt = (props)=>{
    return (
        // Prompt 页面离开时触发
        // 即将进入的下一个路由信息
        <Prompt message={(location)=>{
            const state = window.sessionStorage.getItem("user");
          if ((location.pathname === "/" || location.pathname === "/home") &&state === "false"){
            return false;
          } else if (location.pathname !== "/" && location.pathname !== "/home" && state === "true"){
            return false;
          }
          return true;
        }}></Prompt>
    )
    
}

export default withRouter(MyPrompt)
   